package com.hxk.pojo;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="t_father")
public class Father implements Serializable {

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="fatherId")
	private Integer fatherId;
	
	@Column(name="name")
	private String name;
	
	@OneToMany(mappedBy="father",cascade=CascadeType.PERSIST, fetch=FetchType.EAGER)
	private Set<Son> sons = new HashSet<>();

	
	public Integer getFatherId() {
		return fatherId;
	}


	public void setFatherId(Integer fatherId) {
		this.fatherId = fatherId;
	}


	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public Set<Son> getSons() {
		return sons;
	}


	public void setSons(Set<Son> sons) {
		this.sons = sons;
	}


	@Override
	public String toString() {
		return "Father [fatherId=" + fatherId + ", name=" + name + "]";
	}
	
}
